/**
 *  Created by Choisaaaa on 2018/4/29.
 */
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Switch, Redirect, Route, Link } from 'react-router-dom'
import ProductRouter  from 'page/product/router.jsx';
import HeadLineRouter  from 'page/headLine/router.jsx';
import Layout from "component/layout/layout.jsx"
//页面
import Home from "page/home/home.jsx";
import Login from "page/login/login.jsx";
import UserList from  "page/user-list/user-list.jsx";
import OrderList from  "page/order/order-list.jsx";
import OrderDetail from  "page/order/order-detail.jsx";
import OrderFind from  "page/order/order-find.jsx";
import ErrorPage from "page/error/error.jsx";

class App extends React.Component{
    render(){
        let LayoutRouter = (
            <Layout>
                <Switch>
                    <Route exact path="/" component={Home}/>
                    <Route path="/product" component={ProductRouter}/>
                    <Route path="/product-category" component={ProductRouter}/>
                    <Route path="/order/index" component={OrderList}/>
                    <Route path="/order/detail/:orderNumber" component={OrderDetail}/>
                    <Route path="/order/find" component={OrderFind}/>
                    <Route path="/user/index" component={UserList}/>
                    <Route path="/headLine" component={HeadLineRouter}/>
                    <Redirect exact from="/order" to="/order/index"/>
                    <Redirect exact from="/user" to="/user/index"/>
                    <Route component={ErrorPage}/>
                </Switch>
            </Layout>
        );
        return(
            <Router>
                <Switch>
                    <Route path="/login" component={Login}/>
                    <Route path="/" render={ props => LayoutRouter}/>
                </Switch>
            </Router>
        )
    }
}
ReactDOM.render(
    <App/>,
    document.getElementById("app")
);
